package com.mall.biz.eshop;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.mall.custom.dao.read.EshopTouchReadMapper;
import com.mall.custom.dao.write.EshopTouchWriteMapper;
import com.mall.pojo.EshopTouchExample;
import com.mall.query.eshop.EshopTouchQuery;

@Service
/**
 * 运营主动联系
 * @author Administrator
 *
 */
public class EshopTouchBizImpl {
	@Autowired
	private EshopTouchReadMapper eshopTouchReadMapper;
	@Autowired
	private EshopTouchWriteMapper eshopTouchWriteMapper;
	
	public EshopTouchExample getEshopTouchExampleByQuery(EshopTouchQuery eshopTouchQuery){
		EshopTouchExample example = new EshopTouchExample();
		if(eshopTouchQuery.getPage() != null){
			example.setLimit(eshopTouchQuery.getPage().getLength());
			example.setStart(eshopTouchQuery.getPage().getBegin());
		}
		if(StringUtils.isNotBlank(eshopTouchQuery.getOrderBy())){
			example.setOrderByClause(eshopTouchQuery.getOrderBy());
		}
		com.mall.pojo.EshopTouchExample.Criteria criteria = example.createCriteria();
		if(StringUtils.isNotBlank(eshopTouchQuery.getKeyWord())){
			criteria.andPyNameLike("%"+eshopTouchQuery.getKeyWord()+"%");
		}
		
		if(eshopTouchQuery.getStatus() != null){
			criteria.andStatusEqualTo(eshopTouchQuery.getStatus());
		}
		if(eshopTouchQuery.getOnlyKey() != null){
			criteria.andCommOnlyKeyEqualTo(eshopTouchQuery.getOnlyKey());
		}
		
		return example;
	}
}
